import 'package:flutter/material.dart';

///GestureDetector(手势识别) 控件没有图像显示,只是检测用户输入的手势,当用户点击Container时,GestureDetector会调用onTap回调
///然后打印信息到控制台,还有其他手势控制如,点击,拖动,缩放
void main() {
  runApp(MaterialApp(
    title: 'Flutter教程02-2',
    home:MyButton(),
  ));
}

class MyButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('MyButton被监听了');
      },
      child: Container(
        height: 36.0,
        padding: const EdgeInsets.all(8.0),
        margin: const EdgeInsets.symmetric(horizontal: 8.0),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(5.0),
            color: Colors.lightGreen[500]
        ),
        child: Center(
          child: Text('点击监听'),
        ),
      ),
    );
  }
}
